package com.example.demo2.exception;

import com.example.demo2.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Result handler(ServiceException serviceException){
        return Result.error(serviceException.getMsg(),serviceException.getCode());
    }
}

